package com.example.day03_mvp.base;


import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public abstract class BaseObserver<T> implements Observer<T> {
    public BaseModel model;
    private Disposable disposable;

    public BaseObserver(BaseModel model) {
        this.model = model;
    }
    public void onSubrscibe(Disposable d){
        this.disposable=d;
        model.addDisposable(d);
    }
    public void onNext(T t){
        onSuccess(t);
        //disposable.dispose();
        model.removedisposable(disposable);
    }
    public void onError(Throwable e){
        onFali(e.getMessage());
    }
    public void onComplete(){}
    protected abstract void onFali(String message);

    protected abstract void onSuccess(T t);
}
